package com.gxuwz.cyhschool;

import androidx.appcompat.app.AppCompatActivity;
import androidx.cardview.widget.CardView;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class message extends Activity {


    private ListView mListView;

    private String [] titles = {"活动通知","奖学金通知","充值情况"};

    private String [] prices = {"奖励通知","评定通知","活动通知"};

    private String [] tvprices = {"期末活动开始了","奖学金到账了","充值问题解决"};

    private String [] times = {"14:58:02","14:09:02","14:01:02"};
    private int [] icons = {R.drawable.balance,R.drawable.balloon,R.drawable.bank};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);

//        CardView cardView1=findViewById(R.id.cd_message);
//        Intent intent1=new Intent(message.this,messagecontent.class);
//        cardView1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                startActivity(intent1);
//
//            }
//        });
        mListView = (ListView) findViewById(R.id.lv);
        MyBaseAdapter mAdapter = new MyBaseAdapter();
        mListView.setAdapter(mAdapter);

        mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(message.this, messagecontent.class);
                startActivity(intent);
            }
        });




        ImageView imageView2=findViewById(R.id.iv_my);
        Intent intent2=new Intent(message.this,my.class);
        imageView2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(intent2);
                finish();
            }



        });

        ImageView imageView3=findViewById(R.id.iv_main);
        Intent intent3=new Intent(message.this,MainActivity.class);
        imageView3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(intent3);
                finish();
            }
        });















    }

    class MyBaseAdapter extends BaseAdapter {
        @Override
        public int getCount(){
            return titles.length;
        }
        @Override
        public Object getItem(int position){
            return titles[position];
        }
        @Override
        public long getItemId(int position){
            return position;
        }
        @Override
        public View getView(int position , View convertView , ViewGroup parent){
            View view = View.inflate(message.this,R.layout.list_itemmessage,null);
            TextView title = (TextView) view.findViewById(R.id.title);
            TextView price = (TextView) view.findViewById(R.id.price);
            TextView pricee = (TextView) view.findViewById(R.id.tv_price);
            TextView timee = (TextView) view.findViewById(R.id.time);
            ImageView iv = (ImageView) view.findViewById(R.id.iv);

            title.setText(titles[position]);
            price.setText(prices[position]);
            pricee.setText(tvprices[position]);
            timee.setText(times[position]);

            iv.setBackgroundResource(icons[position]);
            return view;
        }
    }
}